package com.coman404.mvc.demo.controller;

import com.coman404.mvc.annotation.RequestBody;
import com.coman404.mvc.annotation.RequestMapping;
import com.coman404.mvc.annotation.RequestParam;
import com.coman404.mvc.annotation.RestController;


@RestController
@RequestMapping("/test")
public class TestController {

    @RequestMapping("/hello")
    public String hello(@RequestParam("name") String name){
        return "hello " + name;
    }

    @RequestMapping("/obj")
    public VO world(@RequestParam("name") String name,@RequestParam("age")Integer age){
        VO vo = new VO();
        vo.setAge(age);
        vo.setName(name);
        return vo;
    }

    @RequestMapping(value = "/obj2",method = "POST")
    public VO world2(@RequestBody VO vo){
        vo.setName("post:"+vo.getName());
        return vo;
    }

    public class VO{
        private String name;
        private int age;
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public int getAge() {
            return age;
        }
        public void setAge(int age) {
            this.age = age;
        }
    }

}
